package com.xl.enums;


import lombok.AllArgsConstructor;

import java.util.ArrayList;

@AllArgsConstructor
public enum DeviceTypeEnum {

    PCF(1, "PCF"),
    DNS(2, "DNS"),
    MC(3, "MC"),
    MDS(4, "MDS"),
    VG_IN(5, "5G-IN"),
    MSC(6, "MSC"),
    FAS(7, "FAS"),
    UPF(8, "UPF");

    private Integer type;
    private String info;

    public static String getInfoByType(Integer type) {
        String info = "";
        for (DeviceTypeEnum deviceTypeEnum : values()) {
            if (deviceTypeEnum.type.equals(type)) {
                info = deviceTypeEnum.info;
            }
        }
        return info;
    }

    public static Integer getTypeByInfo(String provideInfo) {
        for (DeviceTypeEnum value : values()) {
            if (value.info.equals(provideInfo)) return value.type;
        }
        throw new RuntimeException("不存在该设备类型");
    }

    public static String[] getAllInfo() {
        ArrayList<String> infos = new ArrayList<>();
        for (DeviceTypeEnum value : values()) {
            infos.add(value.info);
        }
        return infos.toArray(new String[]{});
    }
}
